<template>
  <el-dialog
    :title="'简历详情'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="120px">
    <el-form-item label="姓名" prop="resName">
      <el-input v-model="dataForm.resName" placeholder="姓名" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="年龄" prop="resAge">
      <el-input v-model="dataForm.resAge" placeholder="年龄" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="性别" prop="resGender">
      <el-input v-model="dataForm.resGender" placeholder="性别" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="学历" prop="resEducation">
      <el-input v-model="dataForm.resEducation" placeholder="学历" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="毕业院校" prop="resCollege">
      <el-input v-model="dataForm.resCollege" placeholder="毕业院校" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="专业名称" prop="resMajor">
      <el-input v-model="dataForm.resMajor" placeholder="专业名称" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="毕业时间" prop="resOutCollege">
      <el-input v-model="dataForm.resOutCollege" placeholder="毕业时间" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="工作年限" prop="resWorkYear">
      <el-input v-model="dataForm.resWorkYear" placeholder="工作年限" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="手机号码" prop="resMobile">
      <el-input v-model="dataForm.resMobile" placeholder="手机号码" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="期望工作地区" prop="resExpectedArea">
      <el-input v-model="dataForm.resExpectedArea" placeholder="期望工作地区" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="期望岗位" prop="resExpectedOccupation">
      <el-input v-model="dataForm.resExpectedOccupation" placeholder="期望岗位" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="期望月薪" prop="resExpectedSalary">
      <el-input v-model="dataForm.resExpectedSalary" placeholder="期望月薪" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="工作经历" prop="resWorkExperience">
      <el-input v-model="dataForm.resWorkExperience" placeholder="工作经历" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="录入时间" prop="myTime">
      <el-input v-model="dataForm.myTime" placeholder="录入时间" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="简历来源" prop="myResFrom">
      <template>
        <el-radio v-model="dataForm.myResFrom" :label="1"  :disabled="true">自己录入</el-radio>
        <el-radio v-model="dataForm.myResFrom" :label="2" :disabled="true">朋友分享</el-radio>
      </template>
    </el-form-item>
    <el-form-item label="是否同意分享" prop="resShare">
      <template>
        <el-radio v-model="dataForm.resShare" :label="1" >同意</el-radio>
        <el-radio v-model="dataForm.resShare" :label="0">不同意</el-radio>
      </template>
      
    </el-form-item>
        <h3>面试评价</h3>
        <div v-for="data of dataList" :key="data.recId">
            <div style="border: 1px dashed paleturquoise;margin:5px 0px 5px 60px">
                <p>评价:{{data.recImpression}}</p>
                <p>评分:
                <span v-if="data.recScore=='1'">极差</span>
                <span v-if="data.recScore=='2'">失望</span>
                <span v-if="data.recScore=='3'">一般</span>
                <span v-if="data.recScore=='4'">满意</span>
                <span v-if="data.recScore=='5'">惊喜</span>
                </p>
                评价时间:{{data.recTime}}  评价人:{{data.userName}}
            </div>

        </div>

         <el-form-item label="面试记录" prop="recImpression">
             <el-input type="textarea" v-model="dataForm.recImpression" placeholder="面试记录"></el-input>
         </el-form-item>
        <el-form-item label="评分" prop="recScore">
          <el-rate
            v-model="dataForm.recScore"
            show-text>
          </el-rate>
         <!-- <el-input v-model="dataForm.recScore" placeholder="评分"></el-input> -->
        </el-form-item>

        <el-form-item label="简历状态" prop="myResState">
            <template>
              <el-select v-model="dataForm.myResState" placeholder="请选择">
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </template>
      
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
    
</template>


<script>
  export default {
    data () {
      return {
        visible: false,
        dataList: [],
        dataForm: {
          resId: 0,
          resName: '',
          resAge: '',
          resGender: '',
          resEducation: '',
          resCollege: '',
          resMajor: '',
          resOutCollege: '',
          resWorkYear: '',
          resMobile: '',
          resExpectedArea: '',
          resExpectedOccupation: '',
          resExpectedSalary: '',
          resWorkExperience: '',
          myTime: '',
          resShare: '',
          key: '',
        //   resHrid: '',
        //   resFrom: '',
        //   resBz1: '',
        //   resBz2: ''
          recImpression:'',
          recScore:'',
          myResState:'',
          myResFrom:'',
        },
         options1: [{
          value: 0,
          label: '预约'
        }, {
          value: 1,
          label: '储备'
        }, {
          value: 2,
          label: '入职'
        }, {
          value: 3,
          label: '无效'
        }],
        dataRule: {
          resName: [
            { required: true, message: '姓名不能为空', trigger: 'blur' }
          ],
          resAge: [
            { required: true, message: '年龄不能为空', trigger: 'blur' }
          ],
          resGender: [
            { required: true, message: '性别不能为空', trigger: 'blur' }
          ],
          resEducation: [
            { required: true, message: '学历不能为空', trigger: 'blur' }
          ],
          resCollege: [
            { required: true, message: '毕业院校不能为空', trigger: 'blur' }
          ],
          resMajor: [
            { required: true, message: '专业名称不能为空', trigger: 'blur' }
          ],
          resOutCollege: [
            { required: true, message: '毕业时间不能为空', trigger: 'blur' }
          ],
          resWorkYear: [
            { required: true, message: '工作年限不能为空', trigger: 'blur' }
          ],
          resMobile: [
            { required: true, message: '手机号码不能为空', trigger: 'blur' }
          ],
          resExpectedArea: [
            { required: true, message: '期望工作地区不能为空', trigger: 'blur' }
          ],
          resExpectedOccupation: [
            { required: true, message: '期望岗位不能为空', trigger: 'blur' }
          ],
          resExpectedSalary: [
            { required: true, message: '期望月薪不能为空', trigger: 'blur' }
          ],
          resWorkExperience: [
            { required: true, message: '工作经历不能为空', trigger: 'blur' }
          ],
          myTime: [
            { required: true, message: '录入时间不能为空', trigger: 'blur' }
          ],
          resShare: [
            { required: true, message: '是否同意分享不能为空', trigger: 'blur' }
          ],
        //   resHrid: [
        //     { required: true, message: '录入人不能为空', trigger: 'blur' }
        //   ],
        //   resFrom: [
        //     { required: true, message: '简历来源不能为空', trigger: 'blur' }
        //   ],
        //   resBz1: [
        //     { required: true, message: '备注1不能为空', trigger: 'blur' }
        //   ],
        //   resBz2: [
        //     { required: true, message: '备注2不能为空', trigger: 'blur' }
        //   ]
        recImpression:[
            { required: true, message: '面试记录不能为空', trigger: 'blur' }
        ],
     
        recScore:[
            { required: true, message: '评分不能为空', trigger: 'blur' }
        ],
        myResState:[
             { required: true, message: '简历状态不能为空', trigger: 'blur' }
        ],
        }
      }
    },
    methods: {
      init (id) {
        this.dataForm.resId = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.resId) {
            this.$http({
              url: this.$http.adornUrl(`/generator/resume/info/${this.dataForm.resId}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                //   console.log(data.list)
                //   console.log(data.list[0].resName)
                this.dataForm.resName = data.list[0].resName
                this.dataForm.resAge = data.list[0].resAge
                this.dataForm.resGender = data.list[0].resGender
                this.dataForm.resEducation = data.list[0].resEducation
                this.dataForm.resCollege = data.list[0].resCollege
                this.dataForm.resMajor = data.list[0].resMajor
                this.dataForm.resOutCollege = data.list[0].resOutCollege
                this.dataForm.resWorkYear = data.list[0].resWorkYear
                this.dataForm.resMobile = data.list[0].resMobile
                this.dataForm.resExpectedArea = data.list[0].resExpectedArea
                this.dataForm.resExpectedOccupation = data.list[0].resExpectedOccupation
                this.dataForm.resExpectedSalary = data.list[0].resExpectedSalary
                this.dataForm.resWorkExperience = data.list[0].resWorkExperience
                this.dataForm.myTime = data.list[0].myTime
                this.dataForm.resShare = data.list[0].resShare
                // this.dataForm.resHrid = data.resume.resHrid
                // this.dataForm.resFrom = data.resume.resFrom
                // this.dataForm.resBz1 = data.resume.resBz1
                // this.dataForm.resBz2 = data.resume.resBz2
                this.dataForm.recImpression = data.list[0].recImpression
                this.dataForm.recScore = data.list[0].recScore
                this.dataForm.myResState = data.list[0].myResState
                this.dataForm.myResFrom = data.list[0].myResFrom    
                         
              }
            })
             this.$http({
              url: this.$http.adornUrl(`/generator/record/getListByResId/${this.dataForm.resId}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                // console.log(data.list)
                this.dataList = data.list
                
              } else{
                  this.dataList = []
              }
            })
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/generator/resume/updateByResId`),
              method: 'post',
              params: this.$http.adornParams({
                'resId': this.dataForm.resId || undefined,
                // 'resName': this.dataForm.resName,
                // 'resAge': this.dataForm.resAge,
                // 'resGender': this.dataForm.resGender,
                // 'resEducation': this.dataForm.resEducation,
                // 'resCollege': this.dataForm.resCollege,
                // 'resMajor': this.dataForm.resMajor,
                // 'resOutCollege': this.dataForm.resOutCollege,
                // 'resWorkYear': this.dataForm.resWorkYear,
                // 'resMobile': this.dataForm.resMobile,
                // 'resExpectedArea': this.dataForm.resExpectedArea,
                // 'resExpectedOccupation': this.dataForm.resExpectedOccupation,
                // 'resExpectedSalary': this.dataForm.resExpectedSalary,
                // 'resWorkExperience': this.dataForm.resWorkExperience,
                // 'resTime': this.dataForm.resTime,
                'resShare': this.dataForm.resShare,
                'recImpression':this.dataForm.recImpression,
                'recScore':this.dataForm.recScore,
                'myResState':this.dataForm.myResState,

                // 'resHrid': this.dataForm.resHrid,
                // 'resFrom': this.dataForm.resFrom,
                // 'resBz1': this.dataForm.resBz1,
                // 'resBz2': this.dataForm.resBz2
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
</script>
